<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2025/9/3 15:16
 */

namespace App\Controller\User;


use App\Controller\ApiController;
use App\Request\User\AccountListRequest;
use App\Request\User\AccountRemoveRequest;
use App\Request\User\AccountSaveRequest;
use App\Service\User\AccountService;
use Hyperf\Di\Annotation\Inject;

class AccountController extends ApiController
{


    #[Inject]
    protected AccountService $accountService;


    public function accountList(AccountListRequest $request)
    {
        $accountData = $this->accountService->accountList();

        return $this->responseOk($accountData);
    }


    /**
     * 账号保存
     * @param AccountSaveRequest $request
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function accountSave(AccountSaveRequest $request)
    {
        $data = $request->validated();
        $accountId = $this->accountService->accountSave($data);
        return $this->responseOk(['id' => $accountId]);
    }


    public function accountRemove(AccountRemoveRequest $request)
    {
        $data = $request->validated();

        $this->accountService->accountRemove($data['id']);

        return $this->responseOk();
    }
}